﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Resources/Master.Master" AutoEventWireup="true" CodeBehind="GeneralReport.aspx.cs" Inherits="Assignment_3.Feature___Reports.GeneralReport" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">

        google.load("visualization", "1", { packages: ["table", "corechart"] });

        function drawChart() {
            //Table
            var hdValue = document.getElementById("<%=hdData.ClientID%>").value;
            var response = $.parseJSON(hdValue);

            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Guests');
            data.addColumn('string', 'Room No.');
            data.addColumn('date', 'Check-in Date');
            for (var i = 0; i < response.length; i++) {
                var row = new Array();
                row[0] = response[i].Guests;
                row[1] = response[i].RoomNo;
                row[2] = new Date(response[i].Check_in);
                data.addRow(row);
            }


            var formatter_long = new google.visualization.DateFormat({ pattern: 'yyyy-MM-dd' });
            formatter_long.format(data, 2);

            var options = {
            };
            options['page'] = 'enable';
            options['pageSize'] = 20;
            options['pagingButtonsConfiguration'] = 'auto';
            chart = new google.visualization.Table(document.getElementById('chart_div'));
            chart.draw(data, options);
        }
    </script>
    <script type="text/javascript">
        $(document).ready(drawChart);
    </script>
    <script type="text/javascript">
        function PrintPanel() {
            var panel = document.getElementById("<%=printPnl.ClientID %>");
            var printWindow = window.open('', '', 'height=400,width=800');
            printWindow.document.write('<html><head><title>DIV Contents</title>');
            printWindow.document.write('</head><body >');
            printWindow.document.write(panel.innerHTML);
            printWindow.document.write('</body></html>');
            printWindow.document.close();
            setTimeout(function () {
                printWindow.print();
            }, 500);
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="margin-top: 20px; margin-left: 3%; margin-right: 3%">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Panel ID="printPnl" runat="server">
            <h1>General Report</h1>
            Please enter a Room Number:<asp:TextBox ID="roomnoTbx" runat="server" AutoPostBack="True" OnTextChanged="roomnoTbx_TextChanged" CausesValidation="True" MaxLength="9"></asp:TextBox>
            <ajaxToolkit:FilteredTextBoxExtender ID="roomnoTbx_FilteredTextBoxExtender" runat="server" TargetControlID="roomnoTbx" FilterType="Numbers, UppercaseLetters">
            </ajaxToolkit:FilteredTextBoxExtender>
            <asp:RequiredFieldValidator ID="roomnoVld" runat="server" ControlToValidate="roomnoTbx" Display="Dynamic" ErrorMessage="Please enter a Room Number." Font-Names="Segoe UI" ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:Label ID="emptyLbl" runat="server" ForeColor="Red" Font-Names="segoe ui"></asp:Label>
            <br />
            <br />
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Panel ID="chartPanel" runat="server" Visible="False">
                        <table class="auto-style2">
                            <tr>
                                <td style="vertical-align: top">
                                    <div id="chart_div" style="width: 800px;">
                                    </div>
                                </td>
                                <td style="vertical-align: top; text-align: center;"><span class="style3">Total No. of people:</span><br />
                                    &nbsp;<asp:Label ID="totalLbl" runat="server" Font-Names="segoe ui" Font-Size="72pt" Text="0" Style="font-size: 48pt"></asp:Label>
                                    <br />
                                    <span class="style3">Status : </span>
                                    <asp:Label ID="statusLbl" runat="server" Font-Names="Segoe UI"></asp:Label>
                                </td>
                            </tr>
                        </table>
                        <asp:HiddenField ID="hdData" runat="server" />
                        <br />
                        <asp:Button ID="printBtn" runat="server" OnClientClick="return PrintPanel();" Text="Print Preview" />
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </asp:Panel>
    </div>
</asp:Content>
